package com.nxuer.controllers.pkg01;

import com.alibaba.fastjson.JSONArray;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/RestfulApi")
public class RealTimeDataController {
    @Resource
    RealTimeDataRequester requester;
    @GetMapping("/nowData")
    String nd() {
        JSONArray rep = new JSONArray();
        JSONArray tmp = requester.sendRequest(827);
        if (tmp.size() <= 1) {
            return "{\"code\": 1001, \"message\": \"boom\"}";
        }
        rep.addAll(tmp);
        tmp = requester.sendRequest(23272);
        if (tmp.size() <= 1) {
            return "{\"code\": 1001, \"message\": \"boom\"}";
        }
        rep.addAll(tmp);
        return rep.toJSONString();
    }
}
